<template>
    <el-form
    :model="loginName"
    label-width="120px"
    class="loginForm sign-in-form"
    :rules="rules"
    ref="ruleForm"
  >
    <el-form-item label="邮箱" prop="email">
      <el-input
       placeholder="请输入你的邮箱"
       v-model="loginName.email"
      ></el-input>
    </el-form-item>
    <el-form-item label="密码" prop="password">
      <el-input
        type="password"
        v-model="loginName.password"
        placeholder="请输入你的密码"
      ></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary"
        class="submit-btn"
        @click="resetForm('ruleForm')"
        >提交</el-button
      >
    </el-form-item>
    <!-- 找回密码 -->
    <div class="tiparea">
      <p>忘记密码 <a>立即找回</a></p>
    </div>
  </el-form>
</template>

<script lang = 'ts'>
import {ref,getCurrentInstance} from 'vue'
export default {
  props:{
    loginName:{
      type:Object,
      required:true,
    },
    rules:{
      type:Object,
      required:true
    },
  },
  setup() {
    const {ctx}:any = getCurrentInstance()
    // 登录方法
    const resetForm = (ruleForm:string)=>{
       ctx.$refs[ruleForm].validate((valid:boolean) => {
         if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }
    return {resetForm}
  }
}
</script>

<style lang="less" scope>
  /* register */
.loginForm {
  margin-top: 20px;
  background-color: #fff;
  padding: 20px 40px 20px 20px;
  border-radius: 5px;
  box-shadow: 0px 5px 10px #cccc;
}

.submit-btn {
  width: 100%;
}

.tiparea{
  text-align: right;
  font-size: 12px;
  color: #333;
}

.tiparea p a{
  color: #409eff;
}
</style>
